/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 86155
 * date: 2024-03-24
 * Time: 14:31
 *
 * @author 多态
 */

class Animal{
   public String name;
    public int age;
    public void eat(){
        System.out.println(name+"吃饭！");
    }
}
class Dog extends Animal{
    /*@Override
    public void eat(){
        System.out.println(name+"吃狗粮");
    }*/
    Dog(){
        name = "小黄";
    }
    @Override
    public void eat() {
        System.out.println(name+"吃狗粮");
    }
}
class Cat extends Animal{
    public Cat(){
        name = "小猫";
    }
    @Override
    public void eat(){
        System.out.println(name+"吃猫粮");
    }
}
public class Test {
    public static void func2(Animal ainmal){
      ainmal.eat();
    }
    public static Animal func3(){
        return new Cat();
    }
    public static void main(String[] args) {

        Animal animal = func3();
        animal.eat();

    }
    public static void main2(String[] args) {
        Dog dog = new Dog();
        func2(dog);
        Cat cat = new Cat();
        func2(cat);
    }
    public static void main1(String[] args) {
        Dog dog = new Dog();
        Animal animal = new Dog();
        animal.eat();
        dog.eat();
    }
}
